<template>
    <div class="maind" style="padding-top:40px ;height: calc(100% - 5px);">
        <main>
            <el-header>
                <el-input placeholder="搜索参数" size="small" clearable v-model="queryInfo.key"
                    @clear="lookresetForm()"></el-input>
                    <el-dropdown split-button  @click="getassignmentList()"  class="look" size="small"  @command="handleCommand" style="margin-right: 15px;">
                    查询
                    <el-dropdown-menu slot="dropdown">
                        <el-dropdown-item  command="a">高级查询</el-dropdown-item>
                        <el-dropdown-item  command="b">重置查询</el-dropdown-item>
                    </el-dropdown-menu>
                    </el-dropdown>


                    <!-- 高级查询 -->
            <el-dialog  title="高级查询" :visible.sync="dialoglook">
                <el-form :model="queryInfo" :rules="rules" ref="queryInfo" label-width="100px" size="mini"
                    class="demo-ruleForm">
                    <el-row :gutter="20">
                        <el-col :span="12">
                            <el-form-item label="样本编码">
                                <el-input v-model="queryInfo.sampleCode"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="类型名称">
                                <el-input v-model="queryInfo.sampleTypeName"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="采集时间">
                                <el-col :span="5">
                                    <el-date-picker style="width: 85px;" v-model="addassignment.lastFlupDate" type="date" format="yyyy-MM-dd"
                                    value-format="yyyy-MM-dd HH:mm:ss" default-time="00:00:00" placeholder="选择日期时间">
                                </el-date-picker>
                                </el-col>
                                <el-col style="width: 15px; margin: 0 19px;" class="line" :span="2">-</el-col>
                                <el-col :span="5">
                                    <el-date-picker style="width: 85px;" v-model="addassignment.lastFlupDate" type="date" format="yyyy-MM-dd"
                                    value-format="yyyy-MM-dd HH:mm:ss" default-time="00:00:00" placeholder="选择日期时间">
                                </el-date-picker>
                                </el-col>
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="录入时间">
                                <el-col :span="5">
                                    <el-date-picker style="width: 85px;" v-model="addassignment.lastFlupDate" type="date" format="yyyy-MM-dd"
                                    value-format="yyyy-MM-dd HH:mm:ss" default-time="00:00:00" placeholder="选择日期时间">
                                </el-date-picker>
                                </el-col>
                                <el-col style="width: 15px; margin: 0 19px;"  class="line" :span="2">-</el-col>
                                <el-col :span="5">
                                    <el-date-picker style="width: 85px;" v-model="addassignment.lastFlupDate" type="date" format="yyyy-MM-dd"
                                    value-format="yyyy-MM-dd HH:mm:ss" default-time="00:00:00" placeholder="选择日期时间">
                                </el-date-picker>
                                </el-col>
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="年龄范围">
                                <el-col :span="5" >
                                    <el-input style="width: 85px;" v-model="queryInfo.ageStart"></el-input>
                                </el-col>
                                <el-col style="margin: 0 20px;" class="line" :span="2">-</el-col>
                                <el-col :span="5">
                                    <el-input style="width: 85px;" v-model="queryInfo.ageEnd"></el-input>
                                </el-col>
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="姓名">
                                <el-input v-model="queryInfo.sourceName"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="性别">
                                <el-radio-group v-model="queryInfo.sex">
                                    <el-radio label='1'>男</el-radio>
                                    <el-radio label='2'>女</el-radio>
                                </el-radio-group>
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="采集地点">
                                <el-input v-model="queryInfo.collectAddressName"></el-input>
                            </el-form-item>
                        </el-col>

                        <el-col :span="12">
                            <el-form-item label="身份证号">
                                <el-input v-model="queryInfo.sourceIdCard"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="联系电话">
                                <el-input v-model="queryInfo.telephone"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="库存状态">
                                <el-radio-group v-model="queryInfo.state">
                                    <el-radio label='1'>入库</el-radio>
                                    <el-radio label='2'>出库</el-radio>
                                </el-radio-group>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-form-item>
                        <el-button type="primary"  @click="lookget()">查询</el-button>
                        <el-button @click = "resetForm()">取消</el-button>
                        <el-button  @click="lookresetForm()" >重置</el-button>
                    </el-form-item>
                </el-form>
            </el-dialog> 

                <el-button class="add" size="small" @click="addForms()">采集录入</el-button>
                <el-button class="delet" size="small" @click=" machDelete(selectedRows)" :disabled="esdisabled"
                    :class="{ active: esdisabled == false }">审核入库</el-button>
                <el-button class="delet" size="small" @click=" stateDelete(stateRows)" :disabled="btndisabled"
                    :class="{ active: btndisabled == false }">出库</el-button>
                <el-button class="delet" size="small" @click="exportToExcel">导出EXCEL</el-button>
            </el-header>
            <el-table style="height:calc(100% - 85px);" :data="assignmentList" border
                @selection-change="handleSelectionChange" size="mini" :row-style="{ height: '20px' }"
                :cell-style="{ padding: '0px' }">

                <!-- 选择框列 -->
                <el-table-column type="selection" width="50" fixed="left"></el-table-column>

                <el-table-column label="任务编码">
                    <template slot-scope="scope">
                        <span>{{ scope.row.sampleCode }}</span>
                    </template>
                </el-table-column>

                <el-table-column label="姓名" width="200">
                    <template slot-scope="scope">
                        <span>{{ scope.row.sourceName }}</span>
                    </template>
                </el-table-column>
                <el-table-column label="采集地点" width="140">
                    <template slot-scope="scope">
                        <span>{{ scope.row.collectAddressName }}</span>
                    </template>
                </el-table-column>
                <el-table-column label="采集时间" width="200">
                    <template slot-scope="scope">
                        <span>{{ scope.row.receiveDate }}</span>
                    </template>
                </el-table-column>
                <el-table-column label="性别">
                    <template slot-scope="scope">
                        <!-- <span>{{ scope.row.sex }}</span> -->
                        <span v-show="scope.row.sex == '1'">男</span>
                        <span v-show="scope.row.sex == '2'">女</span>
                    </template>
                </el-table-column>
                <el-table-column label="身份证号" width="200">
                    <template slot-scope="scope">
                        <span>{{ scope.row.idCard }}</span>
                    </template>
                </el-table-column>
                <el-table-column label="年龄">
                    <template slot-scope="scope">
                        <span>{{ scope.row.age }}</span>
                    </template>
                </el-table-column>
                <el-table-column label="联系电话">
                    <template slot-scope="scope">
                        <span>{{ scope.row.sourceName }}</span>
                    </template>
                </el-table-column>

                <el-table-column label="是否怀孕">
                    <template slot-scope="scope">
                        <!-- <span>{{ scope.row.pregnant }}</span> -->
                        <span v-show="scope.row.pregnant == '1'">是</span>
                        <span v-show="scope.row.pregnant == '0'">否</span>
                    </template>
                </el-table-column>
                <el-table-column label="孕周">
                    <template slot-scope="scope">
                        <span>{{ scope.row.gestWeek }}</span>
                    </template>
                </el-table-column>
                <el-table-column label="家庭住址" width="150">
                    <template slot-scope="scope">
                        <span>{{ scope.row.telephone }}</span>
                    </template>
                </el-table-column>
                <el-table-column label="录入人员" width="80">
                    <template slot-scope="scope">
                        <span style="margin-left: 10px">{{ scope.row.createBy }}</span>
                    </template>
                </el-table-column>
                <el-table-column label="录入时间" width="200">
                    <template slot-scope="scope">
                        <span>{{ scope.row.createOn }}</span>
                    </template>
                </el-table-column>
                <el-table-column label="审核人" width="80">
                    <template slot-scope="scope">
                        <span>{{ scope.row.createBy }}</span>
                    </template>
                </el-table-column>
                <el-table-column label="样本类型">
                    <template slot-scope="scope">
                        <span>{{ scope.row.sampleTypeName }}</span>
                    </template>
                </el-table-column>
                <el-table-column label="库存状态">
                    <template slot-scope="scope">
                        <!-- <span>{{ scope.row.state }}</span> -->
                        <span v-show="scope.row.state == '2'">出库</span>
                        <span v-show="scope.row.state == '1'" style="color: rgb(11, 178, 212);">入库</span>
                    </template>
                </el-table-column>
                <el-table-column label="备注">
                    <template slot-scope="scope">
                        <span>{{ scope.row.remark }}</span>
                    </template>
                </el-table-column>
                <el-table-column label="状态" fixed="right">
                    <template slot-scope="scope">
                        <!-- <span>{{ scope.row.status }}</span> -->
                        <span v-show="scope.row.status == '0'" style="font-size: 16px;">未审</span>
                        <span v-show="scope.row.status == '2'" style="color: green;">已审</span>
                    </template>
                </el-table-column>
                <el-table-column label="操作" fixed="right" width="100">
                    <template slot-scope="scope">
                        <el-button style="color: #17b3a3; " size="mini" type="text"
                            @click="handleEdit(scope.row)">修改</el-button>
                        <el-button v-if="scope.row.status == 2" style="color: #17b3a3; " size="mini" type="text"
                            @click="handleDelete(scope.row)" disabled>删除</el-button>
                        <el-button v-else style="color: #17b3a3; " size="mini" type="text"
                            @click="handleDelete(scope.row)">删除</el-button>
                    </template>
                </el-table-column>
            </el-table>

            <!-- 添加募捐团队模态框 -->
            <el-dialog v-if="id == ''" title="新增" :visible.sync="dialogFormVisible">
                <el-form :model="sampleCollectList" :rules="rules" ref="sampleCollectList" label-width="100px"
                    class="demo-ruleForm">
                    <el-row :gutter="20">
                        <el-col :span="12">
                            <el-form-item label="样本编码">
                                <el-input v-model="sampleCollectList.samples.sampleCode"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="样本类型">
                                <el-select v-model="sampleCollectList.samples.sampleType" placeholder="请选择活动类型">
                                    <el-option v-for="(item, index) in sampleTypeNameFF" :key="index"
                                        :label="item.label" :value="item.value"></el-option>
                                </el-select>
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="身份证号">
                                <el-input v-model="sampleCollectList.donorsInfo.idCard"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="姓名">
                                <el-input v-model="sampleCollectList.donorsInfo.name"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="特殊资源">
                                <el-radio-group v-model="sampleCollectList.donorsInfo.sex">
                                    <el-radio label='1'>男</el-radio>
                                    <el-radio label='2'>女</el-radio>
                                </el-radio-group>
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="年龄">
                                <el-input-number v-model="sampleCollectList.donorsInfo.age" :min="1" :max="100"
                                    @change="Age" />
                            </el-form-item>
                        </el-col>

                        <el-col :span="12">
                            <el-form-item label="联系电话">
                                <el-input v-model="sampleCollectList.donorsInfo.telephone"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="家庭住址">
                                <el-input v-model="sampleCollectList.donorsInfo.homeAddress"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="采集日期">
                                <el-date-picker v-model="sampleCollectList.samples.receiveDate" type="date" format="yyyy-MM-dd"
                                    value-format="yyyy-MM-dd HH:mm:ss" default-time="00:00:00" placeholder="选择日期时间">
                                </el-date-picker>
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="采集地点">
                                <el-select v-model="sampleCollectList.samples.collectAddress" placeholder="请选择活动类型">
                                    <el-option v-for="(item, index) in collectAddressNameFF" :key="index"
                                        :label="item.label" :value="item.value"></el-option>
                                </el-select>
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="是否怀孕">
                                <el-radio-group v-model="sampleCollectList.samples.pregnant">
                                    <el-radio label='1'>是</el-radio>
                                    <el-radio label='0'>否</el-radio>
                                </el-radio-group>
                            </el-form-item>
                        </el-col>
                        <el-col :span="12" v-show="id">
                            <el-form-item label="孕周">
                                <el-input v-model="sampleCollectList.samples.gestWeek"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="24">
                            <el-form-item label="备注">
                                <el-input type="textarea" :rows="2" placeholder="请输入内容"
                                    v-model="sampleCollectList.samples.remark">
                                </el-input>
                            </el-form-item>
                        </el-col>

                    </el-row>


                    <el-form-item>
                        <el-button type="success" @click="addForm(sampleCollectList)">添加</el-button>
                      
                        <el-button @click="resetForm(sampleCollectList)">取消</el-button>
                    </el-form-item>
                </el-form>
            </el-dialog>

            <!-- 编辑 -->
            <el-dialog v-else title="修改" :visible.sync="dialogFormVisible">
                <el-form :model="sampleCollectListEdit" :rules="rules" ref="sampleCollectListEdit" label-width="100px"
                    class="demo-ruleForm">
                    <el-row :gutter="20">
                        <el-col :span="12">
                            <el-form-item label="样本编码">
                                <el-input v-model="sampleCollectListEdit.samples.sampleCode"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="样本类型">
                                <el-select v-model="sampleCollectListEdit.samples.sampleTypeName" placeholder="请选择活动类型">
                                    <el-option v-for="(item, index) in sampleTypeNameFF" :key="index"
                                        :label="item.label" :value="item.value"></el-option>
                                </el-select>
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="身份证号">
                                <el-input v-model="sampleCollectListEdit.samples.sourceIdCard"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="姓名">
                                <el-input v-model="sampleCollectListEdit.donorsInfo.name"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="特殊资源">
                                <el-radio-group v-model="sampleCollectListEdit.donorsInfo.sex">
                                    <el-radio label='1'>男</el-radio>
                                    <el-radio label='2'>女</el-radio>
                                </el-radio-group>
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="年龄">
                                <el-input-number v-model="sampleCollectListEdit.donorsInfo.age" :min="1" :max="100"
                                    @change="Age" />
                            </el-form-item>
                        </el-col>

                        <el-col :span="12">
                            <el-form-item label="联系电话">
                                <el-input v-model="sampleCollectListEdit.donorsInfo.telephone"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="家庭住址">
                                <el-input v-model="sampleCollectListEdit.donorsInfo.homeAddress"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="采集日期">
                                <el-date-picker v-model="sampleCollectListEdit.samples.createOn" type="date"
                                    value-format="yyyy-MM-dd" placeholder="选择日期时间">
                                </el-date-picker>
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="采集地点">
                                <el-select v-model="sampleCollectListEdit.samples.collectAddressName"
                                    placeholder="请选择活动类型">
                                    <el-option v-for="(item, index) in collectAddressNameFF" :key="index"
                                        :label="item.label" :value="item.value"></el-option>
                                </el-select>
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="是否怀孕">
                                <el-radio-group v-model="sampleCollectListEdit.samples.pregnant">
                                    <el-radio label='1'>是</el-radio>
                                    <el-radio label='0'>否</el-radio>
                                </el-radio-group>
                            </el-form-item>
                        </el-col>
                        <el-col :span="12" v-show="id">
                            <el-form-item label="孕周">
                                <el-input v-model="sampleCollectListEdit.samples.gestWeek"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="24">
                            <el-form-item label="备注">
                                <el-input type="textarea" :rows="2" placeholder="请输入内容"
                                    v-model="sampleCollectListEdit.samples.remark">
                                </el-input>
                            </el-form-item>
                        </el-col>

                    </el-row>


                    <el-form-item>
                        <el-button v-if="id" type="primary" @click="editForm(sampleCollectList)">修改</el-button>
                        <el-button @click="resetForm(sampleCollectList)">取消</el-button>
                    </el-form-item>
                </el-form>
            </el-dialog>





            <pagination :page="queryInfo.page" :componentTotal="total" @changeRows="setRows" @changePage="setPage">
            </pagination>


        </main>
    </div>
</template>

<script>
import Pagination from "./Pagination.vue";
import { excelExportUseJson } from "../excel/xlsx.js";
export default {
    data() {
        return {
            id: '',
            dialogFormVisible: false,
            dialoglook:false,
            esdisabled: true,
            btndisabled: true,
            total: 0,
            queryInfo: {
                t: '',
                page: 1,
                limit: 10,
                key: '',
                sampleCode:"",//样本编码
                sampleTypeName:'',//类型名称
                collectAddressName:'',//采集地点
                receiveDateStart:'',//采集时间
                receiveDateEnd:'',//采集结束时间
                createOnStart:'',//录入时间
                createOnEnd:'',//录入结束时间
                ageStart:'',//年龄
                ageEnd:'',//年龄结束
                sex:'',//性别
                state:'',//库存状态 1 ， 2
                sourceName:'',//姓名
                sourceIdCard:'',//身份证
                telephone:''//手机号
            },
            assignmentList: [],
            //信息录入信息
            sampleCollectList: {
                "t": 1729265045580,
                "samples": {
                    "name": "外周血 | GGG",
                    "sampleCode": "GGG",
                    "sampleType": 106,
                    "sampleTypeName": "外周血",
                    "samplingOrgan": "",
                    "samplingOrganName": "",
                    "samplingSite": "",
                    "samplingSiteName": "",
                    "collectAddress": "15",
                    "collectAddressName": "高密妇幼婚检",
                    "receiveDate": "2024-10-19 13:25:57",
                    "sourceId": 0,
                    "sourceIdCard": "147147147144114",
                    "sourceName": "",
                    "serialNum": "",
                    "applyUserId": "",
                    "applyUser": "",
                    "createOn": "2024-10-19 13:25:57",
                    "createUserId": "",
                    "createBy": "",
                    "modifiedOn": "2024-10-19 13:25:57",
                    "modifiedUserId": "",
                    "modifiedBy": "",
                    "remark": "GGG",
                    "status": "",
                    "pregnant": 0,
                    "gestWeek": ""
                },
                "donorsInfo": {
                    "idCard": "147147147144114",
                    "sampleCode": "GGG",
                    "innerNo": "",
                    "name": "GGG",
                    "sex": 2,
                    "companyName": "",
                    "duty": "",
                    "birthday": "1474-08-11 00:00:00",
                    "age": "99",
                    "mobile": "",
                    "telephone": "GGG",
                    "email": "",
                    "nation": "",
                    "comeFrom": "",
                    "homeAddress": "GGG",
                    "maritalStatus": "",
                    "xisNum": "",
                    "admissionNumber": "",
                    "isInFormed": "",
                    "pathologicalNum": "",
                    "clinicalDiagnosis": "",
                    "clinicNum": "",
                    "checkNum": "",
                    "checkPoint": "",
                    "illnessName": "",
                    "xpublicState": "",
                    "department": "",
                    "diagnosticTime": "",
                    "familyState": "",
                    "familyId": "",
                    "createOn": "2024-10-19 13:25:57",
                    "createUserId": "",
                    "createBy": "",
                    "modifiedOn": "2024-10-19 13:25:57",
                    "modifiedUserId": "",
                    "modifiedBy": "",
                    "remark": "",
                    "back11": "",
                    "back12": "",
                    "back13": "",
                    "back14": "",
                    "back15": "",
                    "back16": "",
                    "back17": "",
                    "back18": "",
                    "back19": "",
                    "back20": "",
                    "back21": "",
                    "back22": "",
                    "back23": "",
                    "back24": "",
                    "back25": "",
                    "back26": "",
                    "back27": "",
                    "back28": "",
                    "back29": "",
                    "back30": "",
                    "back31": "",
                    "back32": "",
                    "back33": "",
                    "back34": "",
                    "back35": "",
                    "back36": "",
                    "back37": "",
                    "back38": "",
                    "back39": ""
                }
            },
            //编辑
            sampleCollectListEdit: {
                t: '',
                samples: {
                    "id": 129,
                    "name": "",
                    "sampleCode": "",
                    "sampleType": 0,
                    "sampleTypeName": "",
                    "samplingOrgan": "",
                    "samplingOrganName": "",
                    "samplingSite": "",
                    "samplingSiteName": "",
                    "collectAddress": "12",
                    "collectAddressName": "",
                    "receiveDate": "",
                    "sourceId": 2,
                    "sourceIdCard": "",
                    "sourceName": "",
                    "serialNum": null,
                    "contractNo": "",
                    "applyUserId": 1,
                    "applyUser": "",
                    "createOn": "",
                    "createUserId": 1,
                    "createBy": "",
                    "modifiedOn": "",
                    "modifiedUserId": 53,
                    "modifiedBy": "",
                    "remark": "2",
                    "status": 0,
                    "pregnant": "0",
                    "gestWeek": ""
                },
                donorsInfo: {
                    "id": 129,
                    "idCard": "",
                    "sampleCode": "",
                    "innerNo": "",
                    "name": "啥XX",
                    "sex": "1",
                    "companyName": "",
                    "duty": "",
                    "birthday": "",
                    "age": 99,
                    "mobile": "",
                    "telephone": "",
                    "email": "",
                    "nation": "",
                    "comeFrom": "",
                    "homeAddress": "",
                    "maritalStatus": null,
                    "xisNum": "",
                    "admissionNumber": "",
                    "isInFormed": null,
                    "pathologicalNum": "",
                    "clinicalDiagnosis": "",
                    "clinicNum": "",
                    "checkNum": null,
                    "checkPoint": "",
                    "illnessName": "",
                    "xpublicState": null,
                    "department": "",
                    "diagnosticTime": null,
                    "familyState": 0,
                    "familyId": 0,
                    "createOn": "",
                    "createUserId": 1,
                    "createBy": "",
                    "modifiedOn": "",
                    "modifiedUserId": 0,
                    "modifiedBy": "",
                    "remark": "",
                    "back11": "",
                    "back12": "",
                    "back13": "",
                    "back14": "",
                    "back15": "",
                    "back16": "",
                    "back17": "",
                    "back18": "",
                    "back19": "",
                    "back20": "",
                    "back21": "",
                    "back22": "",
                    "back23": "",
                    "back24": "",
                    "back25": "",
                    "back26": "",
                    "back27": "",
                    "back28": "",
                    "back29": "",
                    "back30": "",
                    "back31": "",
                    "back32": "",
                    "back33": "",
                    "back34": "",
                    "back35": "",
                    "back36": "",
                    "back37": "",
                    "back38": "",
                    "back39": "",
                    "sourceName": ""
                }
            },

            

            //样本类型---------------------【血型】
            sampleTypeNameFF: [
                { label: "外周血", value: "106" },
                { label: "血浆", value: "32" },
                { label: "血清", value: "12" },
                { label: "血细胞", value: "2312" },
                { label: "白细胞", value: "323" },
                { label: "血小板", value: "1233" },
                { label: "32432", value: "32432" },
            ],
            //采集地点---------------------【婚检】
            collectAddressNameFF: [
                { label: "奎文婚检", value: "奎文婚检" },
                { label: "淮城婚检", value: "淮城婚检" },
                { label: "高新区婚检", value: "高新区婚检" },
                { label: "坊子婚检", value: "坊子婚检" },
                { label: "寒亭婚检", value: "寒亭婚检" },
                { label: "高密婚检", value: "高密婚检" },
                { label: "寿光婚检", value: "寿光婚检" },
            ],
            collectAdd:[],
            sampleAEE:[],






            
            addassignment: {
                code: '',
                name: '',
                remark: '',
                t: ''
            },
            stateRows: [],
            selectedRows: [],
            rules: {
                idCard: [
                    { min: 15, max: 15, required: true, message: "请填写正确身份证号", trigger: "blur" },
                ],
                sampleTypeName: [
                    { required: true, message: "样本类型不能为空", trigger: "change" },
                ],
                sampleCode: [
                    { required: true, message: "样本编号不能为空", trigger: "blur" },
                ],
                code: [
                    { required: true, message: "任务编码不能为空", trigger: "blur" },
                ],
                name: [
                    { required: true, message: "名称不能为空", trigger: "blur" },
                ],
            },
            pickerOptions: {
                shortcuts: [{
                    text: '今天',
                    onClick(picker) {
                        picker.$emit('pick', new Date());
                    }
                }, {
                    text: '昨天',
                    onClick(picker) {
                        const date = new Date();
                        date.setTime(date.getTime() - 3600 * 1000 * 24);
                        picker.$emit('pick', date);
                    }
                }, {
                    text: '一周前',
                    onClick(picker) {
                        const date = new Date();
                        date.setTime(date.getTime() - 3600 * 1000 * 24 * 7);
                        picker.$emit('pick', date);
                    }
                }]
            },
            listHeader: {
                age:'年龄',
                homeAddress:'家庭住址',
                remark:'备注'
            },
        }
    },
    methods: {
        
        //获取动态的采集地点的下拉列表
        async getcollectAddress() {
            const { data: res } = await this.axios.get("api/biosample/samples/dict-list")
            // console.log(res);
            if (res.code != 0) return this.$message.error("获取任务列表失败");
            let Arr = res.items.map(item => {
                return {
                    label: item.itemName,
                    value: item.itemCode
                }
            });
            this.collectAddressNameFF = Arr;
            this.collectAdd =res.items;
        },



    //获取动态的血样的下拉列表
        async getcollectAddressTTTTTT() {
            const { data: res } = await this.axios.get("api/biosample/sampletype/AllTypeList")
            console.log(res);
            if (res.code != 0) return this.$message.error("获取任务列表失败");
            let Arr = res.list.map(item => {
                return {
                    label: item.name,
                    value: item.id
                }
            });
            this.sampleTypeNameFF = Arr;
            this.sampleAEE =res.list;
        },




















        
        //高级查询
        handleCommand(command) {
        // this.$message('click on item ' + command);
        if (command == "a") {
            this.dialoglook = true;
        }else{
            this.lookresetForm()
        }
      },
      lookget(){
        this.getassignmentList();
        this.dialoglook = false;
      },

        //导出EXCEL
        exportToExcel() {
            let formatList = this.assignmentList
            formatList.map(el => {
                el.sex = el.sex == 1 ? "男" : '女';
                el.pregnant = el.pregnant == 0 ? "否" : "是";
                el.state = el.state == 1 ? "入库" : "出库";
                el.status = el.status == 0 ? "未审" : "已审"
            })
            excelExportUseJson(formatList, this.listHeader, "样本采集信息表");
        },
        //添加操作
        addForms() {
            this.id = '';
            this.getcollectAddress();
            this.getcollectAddressTTTTTT();
            this.sampleCollectList = {
                "t": 1729265045580,
                "samples": {
                    "name": "外周血 | GGG",
                    "sampleCode": "",
                    "sampleType": 106,
                    "sampleTypeName": "外周血",
                    "samplingOrgan": "",
                    "samplingOrganName": "",
                    "samplingSite": "",
                    "samplingSiteName": "",
                    "collectAddress": "15",
                    "collectAddressName": "高密妇幼婚检",
                    "receiveDate": "2024-10-19 13:25:57",
                    "sourceId": 0,
                    "sourceIdCard": "",
                    "sourceName": "",
                    "serialNum": "",
                    "applyUserId": "",
                    "applyUser": "",
                    "createOn": "2024-10-19 13:25:57",
                    "createUserId": "",
                    "createBy": "",
                    "modifiedOn": "2024-10-19 13:25:57",
                    "modifiedUserId": "",
                    "modifiedBy": "",
                    "remark": "",
                    "status": "",
                    "pregnant": 0,
                    "gestWeek": ""
                },
                "donorsInfo": {
                    "idCard": "",
                    "sampleCode": "31",
                    "innerNo": "",
                    "name": "",
                    "sex": 2,
                    "companyName": "",
                    "duty": "",
                    "birthday": "1474-08-11 00:00:00",
                    "age": "99",
                    "mobile": "",
                    "telephone": "",
                    "email": "",
                    "nation": "",
                    "comeFrom": "",
                    "homeAddress": "",
                    "maritalStatus": "",
                    "xisNum": "",
                    "admissionNumber": "",
                    "isInFormed": "",
                    "pathologicalNum": "",
                    "clinicalDiagnosis": "",
                    "clinicNum": "",
                    "checkNum": "",
                    "checkPoint": "",
                    "illnessName": "",
                    "xpublicState": "",
                    "department": "",
                    "diagnosticTime": "",
                    "familyState": "",
                    "familyId": "",
                    "createOn": "2024-10-19 13:25:57",
                    "createUserId": "",
                    "createBy": "",
                    "modifiedOn": "2024-10-19 13:25:57",
                    "modifiedUserId": "",
                    "modifiedBy": "",
                    "remark": "",
                    "back11": "",
                    "back12": "",
                    "back13": "",
                    "back14": "",
                    "back15": "",
                    "back16": "",
                    "back17": "",
                    "back18": "",
                    "back19": "",
                    "back20": "",
                    "back21": "",
                    "back22": "",
                    "back23": "",
                    "back24": "",
                    "back25": "",
                    "back26": "",
                    "back27": "",
                    "back28": "",
                    "back29": "",
                    "back30": "",
                    "back31": "",
                    "back32": "",
                    "back33": "",
                    "back34": "",
                    "back35": "",
                    "back36": "",
                    "back37": "",
                    "back38": "",
                    "back39": ""
                }
            }
            this.dialogFormVisible = true;
        },
        // 获取任务列表
        async getassignmentList() {
            this.queryInfo.t = new Date().getTime()
            const { data: res } = await this.axios.get("api/biosample/samples/list-vo", {
                params: this.queryInfo
            })
            console.log(res);
            this.assignmentList = res.page.list;
            // console.log(this.assignmentList);
            this.total = res.page.totalCount;//最大页数
            if (res.code != 0) return this.$message.error("获取任务列表失败");
        },
        // 分页器
        setRows(val) {
            this.queryInfo.limit = val;
            this.getassignmentList();
        },
        setPage(val) {
            this.queryInfo.page = val;
            this.getassignmentList();
        },
        //批量删除
        handleSelectionChange(selection) {
            this.selectedRows = selection;
            // console.log('Selected Rows:', this.selectedRows);
            this.selectedRows = selection.map(item => {
                if (item.status == 2) return
                this.esdisabled = false
                return item.id
            });
            this.stateRows = selection.map(item => {
                if (item.state == 2) return
                this.btndisabled = false
                return item.id
            });
            if (this.selectedRows.length <= 0) {
                this.esdisabled = true
            }
            if (this.stateRows.length <= 0) {
                this.btndisabled = true
            }
            // console.log( this.selectedRows);
            // if (this.selectedRows.length > 0) {
            //     this.esdisabled = false
            // } else {
            //     this.esdisabled = true
            // }

        },
        machDelete(id) {
            console.log(id);
            this.$confirm(`是否选择[${id}]数据?`, "提示", {
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                type: "warning",
            })
                .then(() => {
                    this.deleteassignment(id);
                })
                .catch(() => {
                    this.$message({
                        type: "info",
                        message: "已取消",
                    });
                });
        },
        stateDelete(id) {
            console.log(id);
            this.$confirm(`是否选择[${id}]数据?`, "提示", {
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                type: "warning",
            })
                .then(() => {
                    this.stateRowss(id);
                })
                .catch(() => {
                    this.$message({
                        type: "info",
                        message: "已取消",
                    });
                });
        },
        async deleteassignment(id) {
            // console.log(this.selectedRows);
            const { data: res } = await this.axios.post("api/biosample/samples/apply", id);
            if (res.code != 0) return this.$message.error("审核入库失败");
            this.$message.success("审核入库成功");
            this.getassignmentList();
        },
        async stateRowss(id) {
            // console.log(this.selectedRows);
            const { data: res } = await this.axios.post("api/biosample/samples/out-stock", id);
            if (res.code != 0) return this.$message.error("出库失败");
            this.$message.success("出库成功");
            this.getassignmentList();
        },
        //编辑
        async editForm() {
            // console.log(1111);
            this.sampleCollectListEdit.samples.name = this.sampleCollectListEdit.samples.sampleTypeName + ' | ' + this.sampleCollectListEdit.samples.sampleCode;
            const { data: res } = await this.axios.post("api/biosample/samples/save-collect", this.sampleCollectListEdit);
            if (res.code != 0) return this.$message.error("修改失败");
            this.$message.success("修改成功");
            this.dialogFormVisible = false;
            this.id = '';
            this.getassignmentList();

        },
        // 表格回显
        async handleEdit(row) {
            // console.log(row);
            this.getcollectAddressTTTTTT();
            this.dialogFormVisible = true;
            this.id = row.id;
            this.sampleCollectListEdit.t = new Date().getTime();
            const { data: res } = await this.axios.get(`api/biosample/sampletype/info/${this.id}`);
            console.log(res);
            // if (res.msg == "success") {
            this.sampleCollectListEdit.samples.id = row.id;
            this.sampleCollectListEdit.donorsInfo.id = row.id;
            this.sampleCollectListEdit.samples.sampleCode = row.sampleCode;
            this.sampleCollectListEdit.samples.sampleName = row.sampleName;
            this.sampleCollectListEdit.samples.sourceIdCard = row.sourceIdCard;
            this.sampleCollectListEdit.donorsInfo.idCard = row.sourceIdCard;
            this.sampleCollectListEdit.donorsInfo.sourceName = row.sourceName;
            this.sampleCollectListEdit.donorsInfo.sex = String(row.sex);
            this.sampleCollectListEdit.donorsInfo.age = row.age;
            this.sampleCollectListEdit.donorsInfo.telephone = row.telephone;
            this.sampleCollectListEdit.donorsInfo.homeAddress = row.homeAddress;
            this.sampleCollectListEdit.samples.createOn = row.createOn;
            this.sampleCollectListEdit.samples.collectAddressName = row.collectAddressName;
            this.sampleCollectListEdit.samples.pregnant = String(row.pregnant);
            this.sampleCollectListEdit.samples.remark = row.remark;
            this.sampleCollectListEdit.samples.gestWeek = row.gestWeek;

            // }
        },
        //重置
        lookresetForm() {
            const defaultQueryInfo = {
                t: '',
                page: 1,
                limit: 10,
                key: '',
                sampleCode: '', // 样本编码
                sampleTypeName: '', // 类型名称
                collectAddressName: '', // 采集地点
                receiveDateStart: '', // 采集时间
                receiveDateEnd: '', // 采集结束时间
                createOnStart: '', // 录入时间
                createOnEnd: '', // 录入结束时间
                ageStart: '', // 年龄
                ageEnd: '', // 年龄结束
                sex: '', // 性别
                state: '', // 库存状态 1 ， 2
                sourceName: '', // 姓名
                sourceIdCard: '', // 身份证
                telephone: '' // 手机号
            };

            this.queryInfo = { ...defaultQueryInfo };
            this.getassignmentList()
        },
        //取消操作
        resetForm() {
            this.dialogFormVisible = false;
            this.dialoglook = false;
            this.id = '';
        },
        //单个删除
        handleDelete(row) {
            console.log(row);
            this.$confirm(`是否删除[${row.id}]数据?`, "提示", {
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                type: "warning",
            })
                .then(() => {
                    this.deleteTeam(row.id);
                })
                .catch(() => {
                    this.$message({
                        type: "info",
                        message: "已取消删除",
                    });
                });
        },
        async deleteTeam(id) {
            const { data: res } = await this.axios.post(`api/biosample/samples/delete`, [id]);
            if (res.code != 0) return this.$message.error("删除失败");
            this.$message.success("删除成功");
            this.getassignmentList();
        },
        //添加新增
        async addForm() {
            // console.log(formName);
            this.sampleCollectList.t = new Date().getTime();
            // this.sampleCollectList.samples.id = this.sampleCollectList.donorsInfo.id = Math.floor(Math.random()*500); 
            this.sampleCollectList.samples.name = this.sampleCollectList.samples.sampleTypeName + '|'  + this.sampleCollectList.samples.sampleCode;
            const { data: res } = await this.axios.post("api/biosample/samples/save-collect", this.sampleCollectList);
            if (res.code != 0) return this.$message.error("新增录入失败");
            this.$message.success("新增录入成功");
            this.dialogFormVisible = false;
            this.getassignmentList();
        },
        //加减框
        Age(val) {
            //    console.log(val);
            this.sampleCollectList.donorsInfo.age = val;
            // console.log(this.sampleCollectList.donorsInfo.age);
        },
    },
    mounted() {
        this.getassignmentList()
    },
    watch: {
        //监听
       'sampleCollectList.samples.collectAddress'(){
            // console.log(this.sampleCollectList.samples.collectAddress);
         for (let i = 0; i < this.collectAdd.length; i++) {
           if (this.collectAdd[i].itemCode == this.sampleCollectList.samples.collectAddress) {
            //  alert(this.collectAdd[i].itemName);
             this.sampleCollectList.samples.collectAddressName = this.collectAdd[i].itemName;
           }
            
         }
       },
         //监听
         'sampleCollectList.samples.sampleType'(){
            // console.log(this.sampleCollectList.samples.collectAddress);
         for (let i = 0; i < this.sampleAEE.length; i++) {
           if (this.sampleAEE[i].code == this.sampleCollectList.samples.sampleType) {
            //  alert(this.collectAdd[i].itemName);
             this.sampleCollectList.samples.sampleTypeName = this.sampleAEE[i].name;
           }
            
         }
       }
    },
    components: {
        Pagination
    }
}
</script>

<style lang="scss" scoped>
::v-deep .el-table .cell {
    text-align: center;
}

main {

    padding: 20px;
    background-color: #fff;
    box-shadow: 0 2px 12px 0 rgba(0, 0, 0, .1);
}

.el-header {
    padding: 0;
    float: left;
    width: 100%;
    ;

    .el-input {
        width: 185px;
        margin-right: 15px;
    }

    .delet {
        color: #fff;
        background-color: #fab6b6;
        border-color: #fab6b6;
    }

    .active {
        color: #fff;
        background-color: #f56c6c;
        border-color: #f56c6c;
    }

    .add {
        color: #fff;
        background-color: #17b3a3;
        border-color: #17b3a3;
    }
}

::v-deep input[aria-hidden="true"] {
    display: none !important;
}

::v-deep .el-radio:focus:not(.is-focus):not(:active):not(.is-disabled) .el-radio__inner {
    box-shadow: none;
}


</style>